iconcache: Always check return value of find_image_offset.
authorWill Newton <will.newton@imgtec.com>
Thu, 12 Jan 2012 11:14:02 +0000 (11:14 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 26 Jan 2012 03:57:52 +0000 (22:57 -0500)
find_image_offset returns 0 if it failed to find a matching image.
Check this return value in _gtk_icon_cache_get_icon to avoid
making bad memory accesses later.

Signed-off-by: Will Newton <will.newton@imgtec.com>
https://bugzilla.gnome.org/show_bug.cgi?id=667745

gtk/gtkiconcache.c

index 53ceccb47aedafac15385c535ce6f92783e056c4..486b1763445a9f9d77cc843213e098316aafcfb7 100644 (file)
@@ -448,6 +448,9 @@ _gtk_icon_cache_get_icon (GtkIconCache *cache,
 
   offset = find_image_offset (cache, icon_name, directory_index);
   
+  if (!offset)
+    return NULL;
+
   image_data_offset = GET_UINT32 (cache->buffer, offset + 4);
   
   if (!image_data_offset)